<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
    <style>
        * {
            margin: 0;
            padding: 0;
        }
        
        li {
            width: 100px;
            height: 100px;
            background-color: aquamarine;
            border: 1px solid #aaa;
            font-size: 30px;
            line-height: 100px;
            text-align: center;
        }
        /*元素隐藏同时不占位置 */
        
        li:nth-of-type(2) {
            display: none;
        }
        /*元素隐藏，但不占位置*/
        
        li:nth-of-type(5) {
            visibility: hidden;
        }
    </style>
</head>

<body>
    <ul>
        <li>1</li>
        <li>2</li>
        <li>3</li>
        <li>4</li>
        <li>5</li>
        <li>6</li>
    </ul>
</body>

</html>